module fadd(
	a,b,result
);
	input [15:0] a;
	input [15:0] b;
	output reg [15:0] result;
	always @ ( * ) begin
		if (a[15] ^ b[15]) begin //The signs are different; need to figure out which magnitude is larger
			if(a[14:0] > b[14:0]) begin //reg 1 is larger, its sign will dominate
				result[15] = a[15];
				result[14:0] = (a[14:0] - b[14:0]);			
			end
			else if(a[14:0] < b[14:0]) begin //reg 2 is larger, its sign will dominate
				result[15] = b[15];
				result[14:0] = (b[14:0] - a[14:0]);
			end
			else begin //They're equal
				result[15:0] = 16'b0;
			end
		end
		else begin //Signs are the same, just add
			result[15] = a[15];
			result[14:0] = (a[14:0] + b[14:0]);
		end
	end
endmodule